package com.tbit.uqbike.constant.enums;

import cn.hutool.core.collection.ListUtil;

import java.util.List;

/**
 * 区域预统计枚举类
 *
 * @Author:BUGTian
 * @DATE: 2022/11/1
 */
public enum AccountDayStatEnum {
    CYCLING_INCOME(1, "骑行收入", "cycling_income"),
    CYCLING_EXPENSES(2, "骑行支出", "cycling_expenses"),
    USER_FINE_INCOME(3, "用户罚款收入", "user_fine_income"),
    USER_PENALTY_EXPENDITURE(4, "用户罚款支出", "user_penalty_expenditure"),
    INCOME_FROM_CYCLING_CARD(5, "骑行卡收入", "income_from_cycling_card"),
    BIKE_CARD_EXPENDITURE(6, "骑行卡支出", "bike_card_expenditure"),
    MEMBERSHIP_CARD_INCOME(7, "会员卡收入", "membership_card_income"),
    MEMBERSHIP_CARD_EXPENDITURE(8, "会员卡支出", "membership_card_expenditure"),
    CARD_FREE_INCOME(9, "免押卡收入", "card_free_income"),
    CHARGE_FREE_CARD_EXPENDITURE(10, "免押卡支出", "charge_free_card_expenditure"),
    COUPON_PACKAGE_INCOME(11, "优惠券套餐收入", "coupon_package_income"),
    COUPON_PACKAGE_EXPENDITURE(12, "优惠券套餐支出", "coupon_package_expenditure"),
    USER_RECHARGE_INCOME(13, "用户充值收入", "user_recharge_income"),
    USER_RECHARGE_EXPENDITURE(14, "用户充值支出", "user_recharge_expenditure"),
    MANUAL_RECHARGE(15, "手工充值", "manual_recharge"),
    MANUAL_DEDUCTION(16, "手工扣款", "manual_deduction"),
    INCOME_FROM_CYCLING_REFUND(17, "骑行退款收入", "income_from_cycling_refund"),
    CYCLING_CONSUMPTION_EXPENDITURE(18, "骑行消费支出", "cycling_consumption_expenditure"),
    OPENING_AND_CLOSING_BALANCE(19, "期初期末余额", "opening_and_closing_balance"),
    DEPOSIT_AT_THE_BEGINNING_AND_END_OF_THE_PERIOD(20, "期初期末押金", "deposit_at_the_beginning_and_end_of_the_period"),
    GIFT_CARD_AT_THE_BEGINNING_AND_END_OF_THE_PERIOD(21, "期初期末礼品卡", "gift_card_at_the_beginning_and_end_of_the_period"),
    DEBT_AT_THE_BEGINNING_AND_END_OF_THE_PERIOD(22, "期初期末欠款", "debt_at_the_beginning_and_end_of_the_period"),
    AMOUNT_OWED(23, "欠款金额", "amount_owed"),
    RECHARGE_AMOUNT_OF_ARREARS(24, "欠款补交充值金额", "recharge_amount_of_arrears"),
    SUPPLEMENTARY_VIRTUAL_AMOUNT_OF_ARREARS(25, "欠款补交虚拟金额", "supplementary_virtual_amount_of_arrears"),
    USER_RECHARGE_GIFT_CARD(26, "用户充值赠送礼品卡", "user_recharge_gift_card"),
    MANUAL_RECHARGE_GIFT_CARD(27, "手工充值礼品卡", "manual_recharge_gift_card"),
    GIFT_CARD_REDEMPTION(28, "礼品卡兑换", "gift_card_redemption"),
    USER_REFUNDS_DEDUCT_GIFT_CARDS(29, "用户退款扣除礼品卡", "user_refunds_deduct_gift_cards"),
    MANUALLY_DEDUCT_GIFT_CARDS(30, "手工扣除礼品卡", "manually_deduct_gift_cards"),
    RIDING_DISCOUNT_GIFT_CARD(31, "骑行抵扣礼品卡", "riding_discount_gift_card"),
    GIFT_CARD_DEDUCTION(32, "礼品卡抵扣费用", "gift_card_deduction"),
    REFUND_OF_GIFT_CARD_DEDUCTION_FEE(33, "礼品卡抵扣费用退款", "refund_of_gift_card_deduction_fee"),
    DEDUCTION_OF_ARTIFICIAL_VIRTUAL_AMOUNT(34, "人工虚拟金额抵扣费用", "deduction_of_artificial_virtual_amount"),
    REFUND_OF_ARTIFICIAL_VIRTUAL_AMOUNT_DEDUCTION_FEE(35, "人工虚拟金额抵扣费用退款", "refund_of_artificial_virtual_amount_deduction_fee"),
    MANUALLY_MODIFY_THE_ORDER_DEDUCTION_EXPENSE(36, "人工修改订单抵扣费用", "manually_modify_the_order_deduction_expense"),
    MANUALLY_MODIFY_THE_ORDER_DEDUCTION_FEE_REFUND(37, "人工修改订单抵扣费用退款", "manually_modify_the_order_deduction_fee_refund"),
    OTHER_VIRTUAL_DEDUCTION_EXPENSES(38, "其他虚拟抵扣费用", "other_virtual_deduction_expenses"),
    REFUND_OF_OTHER_VIRTUAL_DEDUCTION_FEES(39, "其他虚拟抵扣费用退款", "refund_of_other_virtual_deduction_fees"),
    TOTAL_NUMBER_OF_VEHICLES(40, "车辆总数", "total_number_of_vehicles"),
    NUMBER_OF_VEHICLES_LAUNCHED(41, "已投放车辆数", "number_of_vehicles_launched"),
    AVERAGE_VEHICLE_INCOME(42, "车均收入", "average_vehicle_income"),
    NUMBER_OF_NEW_USERS(43, "新增用户数", "number_of_new_users"),
    NUMBER_OF_ORDERS_PER_VEHICLE(44, "车均订单数", "number_of_orders_per_vehicle"),
    REVENUE_FROM_MERCHANT_PLATFORM(45, "商户平台收入", "revenue_from_merchant_platform"),
    MERCHANT_PLATFORM_EXPENDITURE(46, "商户平台支出", "merchant_platform_expenditure"),
    WECHAT_MERCHANT_INCOME(47, "微信商户收入", "wechat_merchant_income"),
    WECHAT_MERCHANT_SPENDING(48, "微信商户支出", "wechat_merchant_spending"),
    ALIPAY_MERCHANT_INCOME(49, "支付宝商户收入", "alipay_merchant_income"),
    ALIPAY_MERCHANT_EXPENSES(50, "支付宝商户支出", "alipay_merchant_expenses"),
    REMITTANCE_OF_MERCHANT_INCOME(51, "汇付商户收入", "remittance_of_merchant_income"),
    REMITTING_PAYMENTS_TO_MERCHANTS(52, "汇付商户支出", "remitting_payments_to_merchants"),
    PURCHASE_INCOME(53, "购卡收入", "purchase_income"),
    PURCHASE_COSTS(54, "购卡支出", "purchase_costs"),
    USER_DEPOSIT_INCOME(55, "用户押金收入", "user_deposit_income"),
    USER_DEPOSIT_EXPENDITURE(56, "用户押金支出", "user_deposit_expenditure"),
    OPERATING_INCOME(57, "运营收入", "operating_income"),
    OPERATING_EXPENSES(58, "运营支出", "operating_expenses"),
    NUMBER_OF_OPERATIONAL_VEHICLES(59, "可运营车辆数", "number_of_operational_vehicles"),
    RATE_OF_VEHICLE_DELIVERY(60, "车辆投放率", "rate_of_vehicle_delivery"),
    VEHICLE_LOADING_RATE(61, "车辆上架率", "vehicle_loading_rate"),
    VEHICLE_RENTAL_RATE(62, "车辆出租率", "vehicle_rental_rate"),
    CYCLING_PROFIT_RATE(63, "骑行盈利率", "cycling_profit_rate"),
    REPAIR_COMPLETION_RATE(64, "维修完成率", "repair_completion_rate"),
    EFFICIENCY_OF_DISPATCH(65, "调度有效率", "efficiency_of_dispatch"),
    MOVING_COMPLETION_RATE(66, "挪车完成率", "moving_completion_rate"),
    NUMBER_OF_POWER_CHANGES(67, "换电次数", "number_of_power_changes"),
    NUMBER_OF_MOVES(68, "挪车次数", "number_of_moves"),
    NUMBER_OF_DISPATCHES(69, "调度次数", "number_of_dispatches"),
    CUMULATIVE_NUMBER_OF_USERS(70, "累计用户数", "cumulative_number_of_users"),
    CYCLING_CARD_DEDUCTION_FEE(71, "骑行卡抵扣费用", "cycling_card_deduction_fee"),
    MEMBERSHIP_CARD_DEDUCTION_FEE(72, "会员卡抵扣费用", "membership_card_deduction_fee"),
    COUPON_DEDUCTION_FEE(73, "优惠券抵扣费用", "coupon_deduction_fee"),
    //83-92运维端用
    //93-109数据大屏用
    ACCUMULATED_MILEAGE(102, "累计行驶里程(单位：米)", "accumulated_mileage"),
    ILLEGAL_DISPLACEMENT(110, "非法位移", "illegal_displacement"),
    POWER_FAILURE_ALARM(111, "断电告警", "power_failure_alarm"),
    FAILURE_OF_VEHICLE(112, "车辆故障", "failure_of_vehicle"),

    CREDIT_CARD_VOUCHER_DEDUCTION(118, "卡券抵扣", "credit_card_voucher_deduction"),
    CREDIT_CARD_VOUCHER_DEDUCTION_REFUND(119, "卡券抵扣退款", "credit_card_voucher_deduction_refund"),


    MANUAL_USER_DEPOSIT_INCOME(131, "人工充值押金收入", "manual_user_deposit_income"),

    MANUAL_USER_DEPOSIT_EXPENDITURE(132, "人工退还押金支出", "manual_user_deposit_expenditure"),

    MACHINE_RIDING_TIME(133,"骑行时长", "machine_riding_time"),

    NUMBER_OF_BROKEN_DOWN_VEHICLES(107, "故障车辆数", "number_of_broken_down_vehicles"),
    DAILY_RIDING_USER(123, "每日骑行用户数", "daily_riding_user"),
    NUMBER_OF_REPAIR(125, "维修数", "number_of_repair"),

    NUMBER_OF_ORDER_VEHICLES( 134, "订单车辆数", "number_of_order_vehicles"),
    NUMBER_OF_VALID_ORDER_VEHICLES( 135, "有效订单车辆数", "number_of_valid_order_vehicles"),
    NUMBER_OF_3_LAST_DAY_ORDER_VEHICLES( 136, "3天有订单车辆数", "number_of_3_last_day_order_vehicles"),
    NUMBER_OF_7_LAST_DAY_ORDER_VEHICLES( 137, "7天有订单车辆数", "number_of_7_last_day_order_vehicles"),
    NUMBER_OF_15_LAST_DAY_ORDER_VEHICLES( 138, "15天有订单车辆数", "number_of_15_last_day_order_vehicles"),
    SUM_AND_CNT_OF_SHOULD_ORDER( 139, "应收订单金额和订单数", "sum_and_cnt_of_should_order"),
    NUMBER_OF_3_LAST_DAY_ORDER_USERS( 140, "3天有骑行用户数", "number_of_3_last_day_order_users"),
    NUMBER_OF_7_LAST_DAY_ORDER_USERS( 141, "7天有骑行用户数", "number_of_7_last_day_order_users"),
    NUMBER_OF_15_LAST_DAY_ORDER_USERS( 142, "15天有骑行用户数", "number_of_15_last_day_order_users"),
    RETENTION_RATE_OF_7_DAY_USERS( 143, "新用户7日留存率", "retention_rate_of_7_day_users"),
    RATIO_NUMBER_OF_POWER_CHANGES( 144, "换电有效率", "ratio_number_of_power_changes"),
    COUNT_OF_LOSE_ORDER( 145, "丢单次数", "count_of_lose_order"),
    RATIO_OF_DISPATCH_12_HOUR_HAS_ORDER( 146, "调度后12小时成单率", "ratio_of_dispatch_12_hour_has_order")
    ;
    /**
     * 金额
     */
    private static final String SUM = "_sum";
    /**
     * 数量
     */
    private static final String CNT = "_cnt";
    /**
     * 净收入
     */
    private static final String PURE = "_pure";
    /**
     * 期初期末枚举
     */
    private static final AccountDayStatEnum[] AT_THE_BEGINNING_THE_FINAL_ENUMS =
            {OPENING_AND_CLOSING_BALANCE,
                    DEPOSIT_AT_THE_BEGINNING_AND_END_OF_THE_PERIOD,
                    GIFT_CARD_AT_THE_BEGINNING_AND_END_OF_THE_PERIOD,
                    DEBT_AT_THE_BEGINNING_AND_END_OF_THE_PERIOD};


    /**
     * 运营数据5.0
     */
    private static final AccountDayStatEnum[] OPERATION_ENUMS = {
            OPERATING_INCOME,
            OPERATING_EXPENSES,
            CYCLING_INCOME,
            CYCLING_EXPENSES,
            USER_FINE_INCOME,
            USER_PENALTY_EXPENDITURE,
            PURCHASE_INCOME,
            PURCHASE_COSTS
    };

    /**
     * 运营报表-新 5.0.3
     */
    private static final AccountDayStatEnum[] OPERATION_REPORT_ENUMS = {
            TOTAL_NUMBER_OF_VEHICLES,
            NUMBER_OF_VEHICLES_LAUNCHED,
            NUMBER_OF_NEW_USERS,
            OPERATING_EXPENSES,
            NUMBER_OF_OPERATIONAL_VEHICLES,
            NUMBER_OF_BROKEN_DOWN_VEHICLES,
            CYCLING_INCOME,
            INCOME_FROM_CYCLING_CARD,
            OPENING_AND_CLOSING_BALANCE,
            ACCUMULATED_MILEAGE,
            MACHINE_RIDING_TIME,
            CUMULATIVE_NUMBER_OF_USERS,
            DAILY_RIDING_USER,
            NUMBER_OF_POWER_CHANGES,
            NUMBER_OF_MOVES,
            NUMBER_OF_DISPATCHES,
            REPAIR_COMPLETION_RATE,
            EFFICIENCY_OF_DISPATCH,
            MOVING_COMPLETION_RATE,
            NUMBER_OF_REPAIR,
            NUMBER_OF_ORDER_VEHICLES,
            NUMBER_OF_VALID_ORDER_VEHICLES,
            NUMBER_OF_3_LAST_DAY_ORDER_VEHICLES,
            NUMBER_OF_7_LAST_DAY_ORDER_VEHICLES,
            NUMBER_OF_15_LAST_DAY_ORDER_VEHICLES,
            SUM_AND_CNT_OF_SHOULD_ORDER,
            NUMBER_OF_3_LAST_DAY_ORDER_USERS,
            NUMBER_OF_7_LAST_DAY_ORDER_USERS,
            NUMBER_OF_15_LAST_DAY_ORDER_USERS,
            RETENTION_RATE_OF_7_DAY_USERS,
            RATIO_NUMBER_OF_POWER_CHANGES,
            COUNT_OF_LOSE_ORDER,
            RATIO_OF_DISPATCH_12_HOUR_HAS_ORDER,
            USER_FINE_INCOME
    };

    /**
     * 车辆相关类型
     */
    private static final List<Integer> VEHICLE_TYPE = ListUtil.toList(
            TOTAL_NUMBER_OF_VEHICLES.dataType,
            NUMBER_OF_VEHICLES_LAUNCHED.dataType,
            AVERAGE_VEHICLE_INCOME.dataType,
            CYCLING_INCOME.dataType,
            NUMBER_OF_OPERATIONAL_VEHICLES.dataType,
            USER_FINE_INCOME.dataType,
            NUMBER_OF_ORDERS_PER_VEHICLE.dataType
    );
    /**
     * 订单相关类型
     */
    private static final List<Integer> ORDER_TYPE = ListUtil.toList(OPERATING_INCOME.dataType,
            OPERATING_EXPENSES.dataType,
            CYCLING_INCOME.dataType,
            CYCLING_EXPENSES.dataType,
            USER_FINE_INCOME.dataType,
            USER_PENALTY_EXPENDITURE.dataType,
            INCOME_FROM_CYCLING_CARD.dataType,
            BIKE_CARD_EXPENDITURE.dataType,
            MEMBERSHIP_CARD_INCOME.dataType,
            MEMBERSHIP_CARD_EXPENDITURE.dataType,
            CARD_FREE_INCOME.dataType,
            CHARGE_FREE_CARD_EXPENDITURE.dataType,
            COUPON_PACKAGE_INCOME.dataType,
            COUPON_PACKAGE_EXPENDITURE.dataType,
            PURCHASE_INCOME.dataType,
            PURCHASE_COSTS.dataType);
    /**
     * 车辆运营报表统计相关的类型
     */
    private static final List<Integer> VEHICLE_OPERATION_TYPE = ListUtil.toList(RATE_OF_VEHICLE_DELIVERY.dataType,
            VEHICLE_LOADING_RATE.dataType,
            VEHICLE_RENTAL_RATE.dataType,
            CYCLING_PROFIT_RATE.dataType,
            REPAIR_COMPLETION_RATE.dataType,
            EFFICIENCY_OF_DISPATCH.dataType,
            MOVING_COMPLETION_RATE.dataType,
            NUMBER_OF_ORDERS_PER_VEHICLE.dataType,
            AVERAGE_VEHICLE_INCOME.dataType,
            MACHINE_RIDING_TIME.dataType,
            ACCUMULATED_MILEAGE.dataType,
            CYCLING_INCOME.dataType
    );
    private static final List<Integer> OPERATION_SUM_TYPE = ListUtil.toList(NUMBER_OF_NEW_USERS.dataType,
            NUMBER_OF_POWER_CHANGES.dataType,
            NUMBER_OF_MOVES.dataType,
            NUMBER_OF_DISPATCHES.dataType,
            NUMBER_OF_ORDERS_PER_VEHICLE.dataType,
            AVERAGE_VEHICLE_INCOME.dataType);
    private static final List<Integer> OPERATION_TYPE = ListUtil.toList(TOTAL_NUMBER_OF_VEHICLES.dataType,
            NUMBER_OF_VEHICLES_LAUNCHED.dataType,
            AVERAGE_VEHICLE_INCOME.dataType,
            NUMBER_OF_NEW_USERS.dataType,
            NUMBER_OF_ORDERS_PER_VEHICLE.dataType,
            NUMBER_OF_OPERATIONAL_VEHICLES.dataType,
            CUMULATIVE_NUMBER_OF_USERS.dataType);

    /**
     * 运营数据（5.0.0）
     */
    private static final List<Integer> OPERATIONAL_DATA_TYPE =  ListUtil.toList(
            OPERATING_INCOME.dataType,
            OPERATING_EXPENSES.dataType,
            CYCLING_INCOME.dataType,
            CYCLING_EXPENSES.dataType,
            USER_FINE_INCOME.dataType,
            USER_PENALTY_EXPENDITURE.dataType,
            PURCHASE_INCOME.dataType,
            PURCHASE_COSTS.dataType
            );

    /**
     * 订单分析相关
     */
    private static final List<Integer> ORDER_ANALYSIS_DATA_TYPE = ListUtil.toList(
            NUMBER_OF_ORDERS_PER_VEHICLE.dataType,
            AVERAGE_VEHICLE_INCOME.dataType,
            MACHINE_RIDING_TIME.dataType,
            ACCUMULATED_MILEAGE.dataType,
            CYCLING_INCOME.dataType
    );
    /**
     * 数据类型
     */
    private Integer dataType;
    /**
     * 类型解析
     */
    private String name;
    /**
     * 字段名（前缀）
     */
    private String fieldName;

    AccountDayStatEnum(Integer dataType, String name, String fieldName) {
        this.dataType = dataType;
        this.name = name;
        this.fieldName = fieldName;
    }

    /**
     * 获取期初期末枚举
     *
     * @return
     */
    public static AccountDayStatEnum[] getAtTheBeginningTheFinalEnums() {
        return AT_THE_BEGINNING_THE_FINAL_ENUMS;
    }

    /**
     * 获取运营数据枚举
     * @return
     */
    public static AccountDayStatEnum[] getOperationEnums() {
        return OPERATION_ENUMS;
    }

    /**
     * 获取运营报表-新-统计dataType
     *
     * @return
     */
    public static AccountDayStatEnum[] getOperationReportEnums() {
        return OPERATION_REPORT_ENUMS;
    }

    /**
     * 获取车辆相关的类型
     *
     * @return
     */
    public static List<Integer> getVehicleType() {
        return VEHICLE_TYPE;
    }

    /**
     * 获取订单相关的类型
     *
     * @return
     */
    public static List<Integer> getOrderType() {
        return ORDER_TYPE;
    }

    /**
     * 获取车辆运营报表统计相关的类型
     *
     * @return
     */
    public static List<Integer> getVehicleOperationType() {
        return VEHICLE_OPERATION_TYPE;
    }

    /**
     * 获取运营报表统计需要汇总相关的类型
     *
     * @return
     */
    public static List<Integer> getOperationSumType() {
        return OPERATION_SUM_TYPE;
    }

    /**
     * 获取运营数据相关类型（5.0.0）
     * @return
     */
    public static List<Integer> getOperationalDataType() {
        return OPERATIONAL_DATA_TYPE;
    }

    /**
     * 获取运营报表统计单天数据相关的类型
     *
     * @return
     */
    public static List<Integer> getOperationType() {
        return OPERATION_TYPE;
    }
    /**
     * 订单分析数据相关的类型
     * */
    public static List<Integer> getOrderAnalysisDataType(){
        return ORDER_ANALYSIS_DATA_TYPE;
    }

    public Integer getDataType() {
        return dataType;
    }

    public void setDataType(Integer dataType) {
        this.dataType = dataType;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getFieldName() {
        return fieldName;
    }

    public void setFieldName(String fieldName) {
        this.fieldName = fieldName;
    }

    public String getSumFieldName() {
        return fieldName + SUM;
    }

    public String getCntFieldName() {
        return fieldName + CNT;
    }

    public String getPureFileIdName() {
        return fieldName + PURE;
    }

    public String getSumFieldKey() {
        return "sumTotal_" + dataType;
    }

    public String getCntFieldKey() {
        return "cntTotal_" + dataType;
    }
}
